package biz.obake.team.touchprotector.d.e;

import biz.obake.team.touchprotector.g.c;
import java.util.ArrayList;
import java.util.List;

public class b {

    /* renamed from: a  reason: collision with root package name */
    private static int f1561a = 0;

    /* renamed from: b  reason: collision with root package name */
    private static int f1562b = 0;

    /* renamed from: c  reason: collision with root package name */
    private static int f1563c = 0;

    /* renamed from: d  reason: collision with root package name */
    private static boolean f1564d = false;
    private static long e;
    private static long f;
    private static int g;
    private static int h;
    private static boolean i;
    private static boolean j;
    private static List<a> k = new ArrayList();

    public interface a {
        boolean b(String str);
    }

    private static boolean a(int i2) {
        if ("Locked".equals(c.c("TPService.State"))) {
            return i2 == 3 || i2 == 82 || i2 == 187 || i2 == 276 || i2 == 260 || i2 == 261;
        }
        return false;
    }

    public static boolean b(String str) {
        biz.obake.team.touchprotector.log.a b2 = biz.obake.team.touchprotector.log.a.b();
        b2.d("Key: " + str);
        for (a b3 : k) {
            if (b3.b(str)) {
                return true;
            }
        }
        return false;
    }

    public static synchronized boolean c(int i2, int i3, int i4, boolean z, long j2) {
        synchronized (b.class) {
            if (d(i2, i3, i4, z, j2)) {
                return false;
            }
            boolean z2 = true;
            if (a(i3)) {
                return true;
            }
            f(i2, i3, i4, j2);
            e(i2, i3);
            if (i2 != 0) {
                return false;
            }
            if (h != 2) {
                z2 = false;
            }
            if (i3 != 4) {
                if (i3 != 27) {
                    if (i3 != 80) {
                        if (i3 != 24) {
                            if (i3 != 25) {
                                return false;
                            }
                            if (i && j) {
                                boolean b2 = b("volup+voldown");
                                return b2;
                            } else if (z) {
                                boolean b3 = b("voldown.long");
                                return b3;
                            } else if (z2) {
                                boolean b4 = b("voldown.twice");
                                return b4;
                            } else {
                                boolean b5 = b("voldown");
                                return b5;
                            }
                        } else if (i && j) {
                            boolean b6 = b("volup+voldown");
                            return b6;
                        } else if (z) {
                            boolean b7 = b("volup.long");
                            return b7;
                        } else if (z2) {
                            boolean b8 = b("volup.twice");
                            return b8;
                        } else {
                            boolean b9 = b("volup");
                            return b9;
                        }
                    } else if (z) {
                        boolean b10 = b("focus.long");
                        return b10;
                    } else if (z2) {
                        boolean b11 = b("focus.twice");
                        return b11;
                    } else {
                        boolean b12 = b("focus");
                        return b12;
                    }
                } else if (z) {
                    boolean b13 = b("camera.long");
                    return b13;
                } else if (z2) {
                    boolean b14 = b("camera.twice");
                    return b14;
                } else {
                    boolean b15 = b("camera");
                    return b15;
                }
            } else if (z) {
                boolean b16 = b("back.long");
                return b16;
            } else if (z2) {
                boolean b17 = b("back.twice");
                return b17;
            } else {
                boolean b18 = b("back");
                return b18;
            }
        }
    }

    private static boolean d(int i2, int i3, int i4, boolean z, long j2) {
        long j3 = e;
        boolean z2 = true;
        if (j2 < j3) {
            return true;
        }
        if (!(f1561a == i2 && f1562b == i3 && f1563c == i4 && f1564d == z && j3 == j2)) {
            z2 = false;
        }
        if (!z2) {
            f1561a = i2;
            f1562b = i3;
            f1563c = i4;
            f1564d = z;
            e = j2;
        }
        return z2;
    }

    private static void e(int i2, int i3) {
        boolean z = true;
        if (i2 != 0) {
            if (i2 == 1) {
                z = false;
            } else {
                return;
            }
        }
        if (i3 == 24) {
            i = z;
        } else if (i3 == 25) {
            j = z;
        }
    }

    private static void f(int i2, int i3, int i4, long j2) {
        if (i2 != 0 || i4 > 0) {
            return;
        }
        if (j2 - f > 500 || i3 != g) {
            h = 1;
            f = j2;
            g = i3;
            return;
        }
        h++;
        f = j2;
    }

    public static void g(a aVar) {
        if (!k.contains(aVar)) {
            k.add(aVar);
        }
    }

    public static synchronized void h() {
        synchronized (b.class) {
            i = false;
            j = false;
        }
    }

    public static void i(a aVar) {
        if (k.contains(aVar)) {
            k.remove(aVar);
        }
    }
}
